{php include wl_template('common/header');}
{if $_W['method'] == 'account_list'}
{if empty($_GPC['lct'])}
<ul class="nav nav-tabs" id="myTab">
	<li class="active"><a href="javascript:;">公众号权限</a></li>
</ul>
{/if}
<div class="app-content">
	<div class="app-filter">
		<div class="filter-action">
			<a href="{php echo web_url('cloud/plugin/account_post',['lct'=> $_GPC['lct']])}" class="btn btn-primary">添加新权限</a>
		</div>
		<div class="filter-list">
			<form action="./index.php?" class="form-horizontal form-filter" id="form1">
				{php echo tpl_form_filter_hidden('cloud/plugin/account_list');}
				<input type="hidden" name="lct" value="{$_GPC['lct']}"/>
				<div class="form-group">
					<label class="col-sm-2 control-label">关键字</label>
					<div class="col-sm-9">
						<input class="form-control" name="keyword" placeholder="公众号名称" type="text" value="{$_GPC['keyword']}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label"></label>
					<div class="col-sm-9">
						<button class="btn btn-primary">筛选</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="app-table-list">
		<div class="alert alert-warning">如果没有设置公众号权限,默认拥有全部插件权限</div>
		{if empty($accounts)}
		<div class="no-result">
			<p>还没有相关数据</p>
		</div>
		{else}
		<div class="table-responsive js-table">
			<table class="table table-hover">
				<thead>
				<tr>
					<th>公众号</th>
					<th>应用权限</th>
					<th class="text-right">操作</th>
				</tr>
				</thead>
				{loop $accounts $account}
					<tr>
						<td>{$account['name']}</td>
						<td>
							{loop $account['plugins'] $plugin}
								{if $plugins[$plugin]['name']}{$plugins[$plugin]['name']}；{/if}
							{/loop}
						</td>
						<td class="text-right">
							<a href="{php echo web_url('cloud/plugin/account_post', array('uniacid' => $account['uniacid'],'lct'=> $_GPC['lct']))}" class="btn btn-primary btn-sm">编辑</a>
							<a href="{php echo web_url('cloud/plugin/account_del', array('id' => $account['id']))}" class="btn btn-default btn-sm" data-toggle="ajaxRemove" data-confirm="删除后,公众号将获得全部插件权限,确定删除吗?">删除</a>
						</td>
					</tr>
				{/loop}
			</table>
		</div>
		<div class="pull-right">
			{$pager}
		</div>
		{/if}
	</div>
</div>
{/if}

{if $_W['method'] == 'account_post'}
{if empty($_GPC['lct'])}
<ul class="nav nav-tabs" id="myTab">
	<li class="active"><a href="javascript:;">公众号权限</a></li>
</ul>
{/if}
<div class="app-content">
	<div class="app-form">
		<form class="form-horizontal form form-validate" id="form1" action="" method="post" enctype="multipart/form-data">
			<div class="form-group-title">公众号权限</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">公众号</label>
				<div class="col-sm-9">
					<select name="uniacid" class="form-control select2">
						{loop $all_wechats $wechat}
							<option value="{$wechat['uniacid']}" {if $wechat['uniacid'] == $perm['uniacid']}selected{/if}>{$wechat['name']}</option>
						{/loop}
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">开放插件</label>
				<div class="col-sm-9">
					{loop $plugins $plugin}
						<label class="checkbox checkbox-inline">
							<input type="checkbox" name="plugins[]" value="{$plugin['ident']}" {if in_array($plugin['ident'], $perm['plugins'])}checked{/if}/>{$plugin['name']}
						</label>
					{/loop}
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"></label>
				<div class="col-sm-9">
					<input type="submit" value="提交" class="btn btn-primary min-width">
				</div>
			</div>
		</form>
	</div>
</div>
{/if}
{php include wl_template('common/footer');}